<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<html>
<head>
    <meta charset="utf-8">
    <title>编辑信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="layui/css/layui.css" media="all">
    <link rel="stylesheet" href="css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-container">
    <div class="layui-form layuimini-form" th:object="${Position}">
        <!--    ID、发布人、已招人数不能改动  -->
        <input type="hidden" th:field="*{g_id}">
        <input type="hidden" th:field="*{name}">
        <div class="layui-form-item">
            <label class="layui-form-label required">单位名称</label>
            <div class="layui-input-block">
                <input type="text" th:field="*{department}" lay-verify="required" lay-reqtext="单位名称不能为空" placeholder="请输入单位名称" value="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">岗位名称</label>
            <div class="layui-input-block">
                <input type="text" th:field="*{p_title}" lay-verify="required" lay-reqtext="岗位名称不能为空" placeholder="请输入岗位名称" value="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">薪资待遇</label>
            <div class="layui-input-block">
                <input type="text" th:field="*{salary}" lay-verify="required" lay-reqtext="薪资不能为空" placeholder="请输入薪资" value="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">招收人数</label>
            <div class="layui-input-block">
                <input type="text" th:field="*{lim}" lay-verify="required" lay-reqtext="人数不能为空" placeholder="请输入人数" value="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">已招人数</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" readonly="readonly" th:field="*{quantity}" value="" >
            </div>
            <i></i>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label required">岗位介绍</label>
            <div class="layui-input-block">
                <textarea th:field="*{introduce}" name="content" class="layui-textarea" placeholder="请输入岗位介绍信息"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
            </div>
        </div>
    </div>
</div>
<script src="layui/layui.js" type="text/javascript" charset="UTF-8"></script>
<script src="js/jquery-3.6.3.js"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var NewPosition = data.field;
            $.ajax({
                type: 'POST',
                url: window.location.protocol + '//' + window.location.host + '/editAdPosition',
                dataType: 'html',
                data: JSON.stringify(NewPosition),
                contentType: 'application/json',
                success: function (data) {
                    // 关闭弹出层
                    if (data){
                        parent.layer.msg("提交成功");
                        parent.layui.table.reload('currentTableId');
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    }else {
                        layer.msg("服务器异常，请稍后重试！");
                    }

                },
                error: function () {
                    //console.log(data);
                    layer.alert("请求超时！")
                }
            });
            return false;
        });

    });
</script>
</body>
</html>